// CBData.h: interface for the CCBData class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_CBDATA_H__6BA77849_4E7E_4FF4_9B22_9332EDD10286__INCLUDED_)
#define AFX_CBDATA_H__6BA77849_4E7E_4FF4_9B22_9332EDD10286__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include <vector>

const char NONE_CHESS = 0 ;
const char BLACK_CHESS = '*';
const char WHITE_CHESS = 'o';
const char ILLEGAL_CHESS = '!';

struct ChessStep
{
	int x,y,chess;
};

class CCBData  
{
public:
	void Unset();
	inline void Set(const int x,const int y,const char chess)
	{
		ASSERT ( x>=0 && x<m_size);
		ASSERT ( y>=0 && y<m_size);
		ASSERT ( chess==BLACK_CHESS || chess==WHITE_CHESS);

		m_data[x][y] = chess;

		//add to history
		ChessStep temp = {x,y,chess};
		m_history.push_back(temp);
	}

	inline char Get(const int x,const int y) const
	{
		if ( x>=0 && x<m_size && y>=0 && y<m_size)
		{
			return m_data[x][y];
		}
		else
		{
			return ILLEGAL_CHESS;
		}
	}

	bool GetLastStep(ChessStep & step) const
	{
		if(m_history.size()>0)
		{
			step = m_history.back();
			return true;
		}
		return false;
	}

	void Init();
	CCBData();
	virtual ~CCBData();

	int GetSize() const
	{
		return m_size;
	}

private:
	int m_size;
	char m_data[CHESS_GRID_NUM][CHESS_GRID_NUM];
	std::vector<ChessStep> m_history;

#if defined _DEBUG
public:
	void Dump();
#endif
};

#endif // !defined(AFX_CBDATA_H__6BA77849_4E7E_4FF4_9B22_9332EDD10286__INCLUDED_)
